<%@page contentType="text/html" import="org.jboss.mx.util.MBeanServerLocator,org.jboss.mx.util.MBeanProxy,javax.slee.management.ResourceManagementMBean,javax.management.*,javax.slee.resource.ResourceAdaptorID" %>
<%
	
	MBeanServer server = MBeanServerLocator.locateJBoss();
	ObjectName objectName = new ObjectName("slee:name=ResourceManagementMBean");
	ResourceManagementMBean mbean = (ResourceManagementMBean)MBeanProxy.get(
		                           ResourceManagementMBean.class,
		                           objectName,
		                           server);	
	//out.println(mbean);
	// Create P-CSCF-SipRA stuff
	//ResourceAdaptorID resourceAdapterId = new ResourceAdaptorID("JainSipResourceAdaptor","net.java.slee.sip","1.2");
	org.mobicents.slee.container.component.ResourceAdaptorIDImpl resourceAdapterId = new org.mobicents.slee.container.component.ResourceAdaptorIDImpl("JainSipResourceAdaptor","net.java.slee.sip","1.2");
	String entityName = request.getParameter("x-cscf");//"P-CSCF-SipRA";
	String portNumber = request.getParameter("port");
	try{
		mbean.deactivateResourceAdaptorEntity(entityName);
		Thread.sleep(2000);
		mbean.removeResourceAdaptorEntity(entityName);
	}
	catch(Exception e){
		out.println(e);
	}
	

	java.util.Properties configProps = new java.util.Properties();
	configProps.setProperty("port",portNumber);		 
	configProps.setProperty("cancelWait","1000");		 
	configProps.setProperty("dialogIdleTimeTimeout","7200000");		 
	configProps.setProperty("transports","udp");		 
	configProps.setProperty("ip","127.0.0.1");		 
	mbean.createResourceAdaptorEntity(resourceAdapterId,entityName,configProps);
	mbean.bindLinkName(entityName,entityName); 
	mbean.activateResourceAdaptorEntity(entityName);
	//http://localhost:8080/jmx-console/imsoss.jsp?x-cscf=P-CSCF-SipRA&port=6070


	/*	
	entityName = "I-CSCF-SipRA";
	configProps.setProperty("port","6080");		 
	mbean.createResourceAdaptorEntity(resourceAdapterId,"I-CSCF-SipRA",configProps);
	mbean.bindLinkName(entityName,entityName);
	mbean.activateResourceAdaptorEntity(entityName);

	entityName = "S-CSCF-SipRA";
	configProps.setProperty("port","6090");		 
	mbean.createResourceAdaptorEntity(resourceAdapterId,"S-CSCF-SipRA",configProps);
	mbean.bindLinkName(entityName,entityName);
	mbean.activateResourceAdaptorEntity(entityName);
	
	*/

	/*
	javax.slee.resource.ConfigProperties.Property port = new javax.slee.resource.ConfigProperties.Property("port","java.lang.String","6070");
	javax.slee.resource.ConfigProperties.Property cancelWait = new javax.slee.resource.ConfigProperties.Property("port","java.lang.String","1000");
	javax.slee.resource.ConfigProperties.Property dialogIdleTimeTimeout = new javax.slee.resource.ConfigProperties.Property("port","java.lang.String","7200000");
	javax.slee.resource.ConfigProperties.Property transports = new javax.slee.resource.ConfigProperties.Property("port","java.lang.String","udp");
	javax.slee.resource.ConfigProperties.Property ip = new javax.slee.resource.ConfigProperties.Property("port","java.lang.String","127.0.0.1");
	configProps.addProperty(port);
	configProps.addProperty(cancelWait);
	configProps.addProperty(dialogIdleTimeTimeout);
	configProps.addProperty(transports);
	configProps.addProperty(ip);
	mbean.createResourceAdaptorEntity(resourceAdapterId,entityName,configProps);
	*/
	   
%>	   
<br>
<a href="http://localhost:8080/jmx-console/imsoss.jsp?x-cscf=P-CSCF-SipRA&port=6070">START....p-cscf</a><br>
<a href="http://localhost:8080/jmx-console/imsoss.jsp?x-cscf=I-CSCF-SipRA&port=6080">START....i-cscf</a><br>
<a href="http://localhost:8080/jmx-console/imsoss.jsp?x-cscf=S-CSCF-SipRA&port=6090">START....s-cscf</a><br>
